﻿<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:Microsoft.PlayerFramework"
  >

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Default">
            <SolidColorBrush Color="#44000000" x:Key="ItemBackgroundThemeBrush"/>
        </ResourceDictionary>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush Color="#BBFFFFFF" x:Key="ItemBackgroundThemeBrush"/>
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>

    <Style TargetType="local:ControlPanel">
        <Setter Property="Height" Value="NaN"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ControlPanel">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ApplicationViewStates">
                                <VisualState x:Name="FullScreenLandscape"/>
                                <VisualState x:Name="Filled"/>
                                <VisualState x:Name="FullScreenPortrait"/>
                                <VisualState x:Name="Snapped">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="NonEssentialsNearLeft">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="NonEssentialsNearRight">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="TimelineContainer">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="MediaStates">
                                <VisualState x:Name="Opening"/>
                                <VisualState x:Name="Paused"/>
                                <VisualState x:Name="Playing"/>
                                <VisualState x:Name="Closed"/>
                                <VisualState x:Name="Buffering"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="LayoutStates">
                                <VisualState x:Name="Compact"/>
                                <VisualState x:Name="Normal"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="Border" DataContext="{TemplateBinding ViewModel}">
                            <Border.Resources>
                                <local:BoolToVisibilityConverter x:Key="VisibleIfConverter" />
                            </Border.Resources>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <StackPanel Orientation="Horizontal" x:Name="NonEssentialsNearLeft">
                                        <local:SkipPreviousButton x:Name="SkipPreviousButton" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsSkipPreviousButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Size="70" FontSize="40" Margin="10,0,10,0" StrokeThickness="0" Background="{StaticResource ItemBackgroundThemeBrush}"/>
                                        <local:RewindButton x:Name="RewindButton" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsRewindButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Size="70" FontSize="40" Margin="10,0,10,0" StrokeThickness="0" Background="{StaticResource ItemBackgroundThemeBrush}"/>
                                        <local:SkipBackButton x:Name="SkipBackButton" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsSkipBackButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Size="70" FontSize="40" Margin="10,0,10,0" Padding="0,-10,0,0" StrokeThickness="0" Background="{StaticResource ItemBackgroundThemeBrush}"/>
                                    </StackPanel>

                                    <local:PlayPauseButton x:Name="PlayPauseButton" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsPlayPauseButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Size="140" FontSize="80" Margin="25,0,25,0" StrokeThickness="0" Background="{StaticResource ItemBackgroundThemeBrush}"/>

                                    <StackPanel Orientation="Horizontal" x:Name="NonEssentialsNearRight">
                                        <local:SkipAheadButton x:Name="SkipAheadButton" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsSkipAheadButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Size="70" FontSize="40" Margin="10,0,10,0" Padding="0,-10,0,0" StrokeThickness="0" Background="{StaticResource ItemBackgroundThemeBrush}"/>
                                        <local:FastForwardButton x:Name="FastForwardButton" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsFastForwardButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Size="70" FontSize="40" Margin="10,0,10,0" StrokeThickness="0" Background="{StaticResource ItemBackgroundThemeBrush}"/>
                                        <local:SkipNextButton x:Name="SkipNextButton" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsSkipNextButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Size="70" FontSize="40" Margin="10,0,10,0" StrokeThickness="0" Background="{StaticResource ItemBackgroundThemeBrush}"/>
                                    </StackPanel>
                                </StackPanel>

                                <Grid x:Name="TimelineContainer" Grid.Row="1" Background="{StaticResource ItemBackgroundThemeBrush}">
                                    <Grid Margin="30,4,30,7">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <local:TimeElapsedButton x:Name="TimeElapsedButton" Grid.Column="0" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsTimeElapsedButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Margin="8,0,8,0"/>
                                        <!--<local:Timeline x:Name="Timeline" Grid.Column="1" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsTimelineVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Margin="8,0,8,0"/>-->
                                        <local:Timeline Height="25" Padding="0,10,0,10" x:Name="Timeline" Grid.Column="1" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsTimelineVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Margin="8,0,8,0">
                                            <local:Timeline.SliderStyle>
                                                <Style TargetType="local:SeekableSlider">
                                                    <Setter Property="Foreground" Value="{StaticResource ButtonForegroundThemeBrush}"/>
                                                    <Setter Property="SliderTrackDecreasePressedBackground" Value="{StaticResource ButtonPressedForegroundThemeBrush}" />
                                                    <Setter Property="SliderTrackDecreasePointerOverBackground" Value="{StaticResource ButtonPointerOverForegroundThemeBrush}" />
                                                    <Setter Property="SliderThumbStyle">
                                                        <Setter.Value>
                                                            <Style TargetType="Thumb">
                                                                <Setter Property="Template">
                                                                    <Setter.Value>
                                                                        <ControlTemplate TargetType="Thumb">
                                                                            <Canvas HorizontalAlignment="Center" VerticalAlignment="Top" Margin="-18,-38,18,0">
                                                                                <Grid>
                                                                                    <Ellipse Stroke="{StaticResource ButtonForegroundThemeBrush}" Fill="{StaticResource ButtonPressedForegroundThemeBrush}" StrokeThickness="2" Width="35" Height="35"/>
                                                                                    <Path Fill="{StaticResource ButtonForegroundThemeBrush}" Margin="0,0,0,-7" VerticalAlignment="Bottom" HorizontalAlignment="Center" Data="M 0,0 8,0 4,8Z"/>
                                                                                </Grid>
                                                                            </Canvas>
                                                                        </ControlTemplate>
                                                                    </Setter.Value>
                                                                </Setter>
                                                            </Style>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </local:Timeline.SliderStyle>
                                        </local:Timeline>

                                        <local:TimeRemainingButton x:Name="TimeRemainingButton" Grid.Column="2" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsTimeRemainingButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Margin="8,0,8,0"/>
                                        <local:DurationButton x:Name="DurationButton" Grid.Column="2" ViewModel="{TemplateBinding ViewModel}" Visibility="{Binding IsDurationButtonVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibleIfConverter}}" Margin="8,0,8,0"/>
                                    </Grid>
                                </Grid>
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:MediaPlayer">
        <Setter Property="InteractiveDeactivationMode" Value="All"/>
        <Setter Property="AutoHideBehavior" Value="All"/>
    </Style>

</ResourceDictionary>

